﻿using System;
using JetBrains.Annotations;
using JetBrains.ReSharper.Psi;

namespace MugenMvvmToolkit.ReSharper.PluginModels
{
    public struct TaskBusyHandlerMetaModel
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="TaskBusyHandlerMetaModel" /> class.
        /// </summary>
        public TaskBusyHandlerMetaModel([NotNull] IClass @class, [NotNull] IMethod method,
            [NotNull] IParameter viewModelParameter, IParameter messageParameter, bool isMessageObjectOrString)
            : this()
        {
            if (@class == null) throw new ArgumentNullException("class");
            if (method == null) throw new ArgumentNullException("method");
            if (viewModelParameter == null) throw new ArgumentNullException("viewModelParameter");
            Class = @class;
            Method = method;
            ViewModelParameter = viewModelParameter;
            MessageParameter = messageParameter;
            IsMessageObjectOrString = isMessageObjectOrString;
            Name = method.GetMemberName();
        }

        #endregion

        #region Properties

        public bool IsValid
        {
            get { return Class != null; }
        }

        public bool IsMessageObjectOrString { get; private set; }

        public IClass Class { get; private set; }

        public IMethod Method { get; private set; }

        public IParameter ViewModelParameter { get; private set; }

        public IParameter MessageParameter { get; private set; }

        public string Name { get; private set; }

        #endregion

        #region Methods

        public bool IsSupported(IType type, string name)
        {
            return IsValid;
        }

        #endregion
    }
}